﻿<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />

<link rel="stylesheet" type="text/css" href="__STATIC_ADMIN__/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="__STATIC_ADMIN__/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="__STATIC_ADMIN__/css/iconfont.css" />
<link rel="stylesheet" type="text/css" href="__STATIC_ADMIN__/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>管理员列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理员管理 <span class="c-gray en">&gt;</span> 管理员列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form action="{:url('article/articleList')}" method="get">
		<div class="text-c">
			<input type="text" value="<?php echo $search?>"  class="input-text" style="width:250px" placeholder="输入文章关键词" id="" name="search">
			<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜文章</button>
		</div>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a href="javascript:;" onclick="admin_add('添加文章','{:url('article/articleAdd')}','900','')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加文章</a>
		</span>
	</div>
	<table class="table table-border table-bordered table-bg">
		<thead>
		<tr>
			<th scope="col" colspan="10">普通文章列表</th>
		</tr>
		<tr class="text-c">
			<th width="40">ID</th>
			<th>文章标题</th>
			<th width="80">所属栏目</th>
			<th width="60">作者</th>
			<th width="60">阅读量</th>
			<th width="60">点赞量</th>
			<th width="60">评论量</th>
			<th width="60">推荐</th>
			<th width="130">操作时间</th>
			<th width="100">操作</th>
		</tr>
		</thead>

		<tbody>
		<?php foreach($list as $v){?>
		<tr class="text-c">
			<td><?php echo $v['id']?></td>
			<td><?php echo $v['title']?></td>
			<th><?php echo $v['type_name']?></th>
			<td><?php echo $v['author']?></td>
			<td><?php echo $v['reading_num']?></td>
			<td><?php echo $v['laud_num']?></td>
			<td><?php echo $v['comment_num']?></td>
			<td class="td-status"><span class="label <?php echo $v['is_top'] == 1 ? 'label-success' : 'label-defaunt';?> radius"><?php echo $v['is_top'] == 1 ? '是' : '否';?></span></td>
			<td><?php echo empty($v['update_time']) ? date('Y-m-d H:i:s',$v['create_time']) : date('Y-m-d H:i:s',$v['update_time'])?></td>
			<td class="td-manage">
				<a title="置顶" href="javascript:;" onclick="article<?php echo $v['is_top'] == 1 ? 'NoTop':'Top'?>(this,<?php echo $v['id']?>)" class="ml-5" style="text-decoration:none">
					<i class="Hui-iconfont"><?php echo $v['is_top'] ==1 ? '&#xe699;': '&#xe698;'?></i>
				</a>
				<a title="编辑" href="javascript:;" onclick="rule_edit('角色编辑','<?php echo url('article/articleSave',['id'=>$v['id']])?>','1','1200','810')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
				<a title="删除" href="javascript:;" onclick="admin_del(this,<?php echo $v['id']?>)" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
			</td>
		</tr>
		<?php } ?>

		<?php if(empty($list)){?>
			<tr class="text-l"><td colspan="20">没有找到匹配的记录</td></tr>
		<?php }?>
		</tbody>
	</table>
	<span class="r pages mt-10"><?php echo $page?></span>
</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__STATIC_ADMIN__/js/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC_ADMIN__/js/layer.js"></script>
<script type="text/javascript" src="__STATIC_ADMIN__/js/H-ui.min.js"></script>
<script type="text/javascript" src="__STATIC_ADMIN__/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->


<script type="text/javascript">
/*
	参数解释：
	title	标题
	url		请求的url
	id		需要操作的数据id
	w		弹出层宽度（缺省调默认值）
	h		弹出层高度（缺省调默认值）
*/
function admin_add(title,url,w,h){
	layer_show(title,url,w,h);
}
/*文章-删除*/
function admin_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type:'get',
			url:"<?php echo url('Article/articleDelete')?>",
			data:{"id":id},
			success:function(data){
				if(typeof data === 'string'){
					data = jQuery.parseJSON(data);
				}
				if(data.code ==10000){
					$(obj).parents("tr").remove();
					layer.msg(data.msg,{icon:1,time:1000});
				}else{
					layer.msg(data.msg,{icon:5,time:1000});
				}

			}
		});
	});
}

/*置顶*/
function articleTop(obj,id){
	layer.confirm('确认要置顶吗？',function(index){
		$.ajax({
			type:'post',
			url:"<?php echo url('article/articleTop')?>",
			data:{"id":id,"top":1},
			success:function(data){
				if(typeof data === 'string'){
					data = jQuery.parseJSON(data);
				}
				if(data.code == 10000){
					$(obj).parents("tr").find(".td-manage").prepend('<a title="取消置顶" href="javascript:;" onClick="articleNoTop(this,'+id+')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe699;</i></a>');
					$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">是</span>');
					$(obj).remove();
					layer.msg(data.msg,{icon: 1,time:1000});
				}else{
					layer.msg(data.msg,{icon:5,time:1000});
				}
			}
		});
	});
}

/*取消置顶*/
function articleNoTop(obj,id){
	layer.confirm('确认取消置顶吗？',function(index){
		$.ajax({
			type:'post',
			url:"<?php echo url('article/articleTop')?>",
			data:{"id":id,"top":0},
			success:function(data){
				if(typeof data === 'string'){
					data = jQuery.parseJSON(data);
				}
				if(data.code == 10000){
					$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="articleTop(this,'+id+')" href="javascript:;" title="否"><i class="Hui-iconfont">&#xe698;</i></a>');
					$(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">否</span>');
					$(obj).remove();
					layer.msg(data.msg,{icon: 1,time:1000});
				}else{
					layer.msg(data.msg,{icon:5,time:1000});
				}
			}
		});
	});
}


/*管理员-编辑*/
function rule_edit(title,url,id,w,h){
	layer_show(title,url,w,h);
}
</script>
</body>
</html>